package com.genexususa.eo.facebook.test;

import com.genexususa.eo.facebook.connection.AccountManager;
import com.genexususa.eo.facebook.connection.PageManager;
import com.genexususa.eo.facebook.connection.PostManager;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Emiliano Martinez
 * Date: 1/12/2015
 * Time: 3:10 PM
 * To change this template use File | Settings | File Templates.
 */
public class ConsumeGetAllData {

    public static void main(String[] args){


        AccountManager am = new AccountManager();
        ArrayList<String> accounts = am.getAllAccounts();



        for (String account : accounts) {

            DateTime date = new DateTime();
            date = date.minusDays(1);
            DateTime date2 = date.minusDays(1);
            DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd");

            String today = date.toString(dtf);
            String yesterday = date2.toString(dtf);
            PostManager postManager = new PostManager();
            PageManager pageManager = new PageManager();

            try {
                pageManager.getPageInsights(account, today, yesterday, "c:\\l2tfacebook");
                postManager.getPostInsights(account, today, yesterday, "c:\\l2tfacebook");

            }catch (Exception exc){
                exc.printStackTrace();

            }



        }

    }
}
